package com.ailink.design.pattern.observer.weather;

/**
 * Created by Administrator on 2018/8/14
 */
public class Test {
    public static void main(String[] args) {
        //1 创建目标
        ConcreteWeatherSubject weatherSubject = new ConcreteWeatherSubject();

        //2 创建观察者
        ConcreteObserver observerGirl = new ConcreteObserver();
        observerGirl.setObserverName("黄明的女朋友");
        observerGirl.setRemindThing("我们的第一次约会，地点街心公园，不见不散哦");

        ConcreteObserver observerMum = new ConcreteObserver();
        observerMum.setObserverName("老妈");
        observerMum.setRemindThing("是一个购物的好日子，明天去天虹扫货");

        //3 注册观察者
        weatherSubject.attach(observerGirl);
        weatherSubject.attach(observerMum);

        //4 目标发布天气
        weatherSubject.setWeatherContent("明天天气晴朗，蓝天白云，气温28度");
    }
}
